package com.njts.homework;

import com.njts.innerclass.Utils;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author David GE
 * Date  2025/11/21
 * 1、生成一个4位随机字符串(字符来源于chs数组)
 *
 * 2、发送短信验证码(由于知识储备不足，此处可以通过输出语句进行模拟)
 *
 *
 *
 * 4、将AliyunSendMsg和TencentSendMsg中相同的代码向上进行抽取，将其定义到一个模板类中，然后让AliyunSendMsg和TencentSendMsg继承该类
 */
public class SendMessage {
    static char[] verifyCode;
    static  String phone;
    public static void main(String[] args) {
      verifyCode = Utils.getVerifyCode(4);
        System.out.println("输入登录的手机号码:");
        Scanner scanner = new Scanner(System.in);
        phone = scanner.next();
        // 创建模板
        ISendMsg ali = new AliyunSendMsg();
         sendMessage(ali);
        ISendMsg tencent = new TencentSendMsg();
        verifyCode = Utils.getVerifyCode(4);
        System.out.println("输入登录的手机号码:");
        phone = scanner.next();
        sendMessage(tencent);
    }
    // 模板方法->模板设计模式
    public static void sendMessage(ISendMsg iSendMsg){
            iSendMsg.sendMsg(phone,verifyCode);
    }
}
interface ISendMsg{
    public void sendMsg(String phone,char[] code);
}
class CheckCode{
    String value;
}
class AliyunSendMsg implements ISendMsg {

    @Override
    public void sendMsg(String phone,char[] code) {
        System.out.println("访问阿里云平台给"+phone+"发送验证码"+Arrays.toString(code));
    }
}

class TencentSendMsg implements ISendMsg {
    @Override
    public void sendMsg(String phone,char[] code) {
        System.out.println("访问腾讯云平台给"+phone+"发送验证码"+Arrays.toString(code));
    }
}